<?php

function unescape($str) {
    $str = rawurldecode($str);
    preg_match_all("/(?:%u.{4})|&#x.{4};|&#\d+;|.+/U", $str, $r);
    $ar = $r[0];
    //print_r($ar);
    foreach ($ar as $k => $v) {
        if (substr($v, 0, 2) == "%u") {
            $ar[$k] = iconv("UCS-2BE", "UTF-8", pack("H4", substr($v, -4)));
        } elseif (substr($v, 0, 3) == "&#x") {
            $ar[$k] = iconv("UCS-2BE", "UTF-8", pack("H4", substr($v, 3, -1)));
        } elseif (substr($v, 0, 2) == "&#") {

            $ar[$k] = iconv("UCS-2BE", "UTF-8", pack("n", substr($v, 2, -1)));
        }
    }
    return join("", $ar);
}

class C_TSYZ {

    public function __get($property_name) {

        if (isset($this->$property_name)) {
            return($this->$property_name);
        } else {
            return(NULL);
        }
    }

    public function __set($property_name, $value) {
        $this->$property_name = $value;
    }

    public function ReceiveMsg() {
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
        $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
        return $postObj;
    }

    public function GetMsgType($postObj) {
        return $postObj->MsgType;
    }

    public function Subscribe($postObj) {
        $form_Event = $postObj->Event;
        if ($form_Event == "subscribe") {
            $this->Menu($postObj);
        } else {
            include ("Tpl.php");
            $contentStr = "你怎么忍心取消我的关注啊。搜索 SCNUHM可以加回关注哦。。";
            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;
            exit;
        }
    }

    public function Menu($postObj) {
        $mc = memcache_init();
        $mc->delete($postObj->FromUserName . "_do", 0);
        $mc->set($postObj->FromUserName . "_do", "菜单", 0, 600);
        $menustr = "回复【】内指令，进入相应功能模式：\n".
            "\n【刷】    ：查看微博列表".
            "\n【发布】：发布树洞微博".
            "\n【天气】：查天气".
            "\n【鸡鸡】：调戏小黄鸡".
            "\n【留言】：留言给我们".
            "\n【关于】：关于开发者".
            "\n【菜单】：回到本页";



        $ran = rand(1, 6); //背景图片的切换

        switch ($ran) {
            case 1:$url = "http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/ivvQM83HbMEfjFYIN68IcP1LENYhefIut0vkQSRIevQ!/b/dGNv4O14BgAA&bo=uAElAQAAAAABALo!&rf=photoDetail";
                break;

            case 2:$url = "http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/FA0T606RaK0WcxQkoorczBakPV5sgsJ1tL6*xUNGp5w!/b/dDoq1.12BgAA&bo=uAElAQAAAAABALo!&rf=photoDetail";
                break;

            case 3:$url = "http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/QfyVvs7PjwKG6GbcJe6ivot*1g46iXjaoNCbqMOGFOc!/b/dOw81.14BgAA&bo=uAElAQAAAAABALo!&rf=photoDetail";
                break;

            case 4:$url = "http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/60j8vDfE7pFSEUO1Yf238mdKMln4CQS.jtzWJNOuLw4!/b/dIxD2u1qBgAA&bo=HAIEAQAAAAABADw!&rf=photoDetail";
                break;

            case 5:$url = "http://b400.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/H2ksGQKGimJX0HCjpYYhvUsgktYiiXYFR5vpbINTNGs!/b/dD7Vcu6dDgAA&bo=*gEFAgAAAAABAN8!&rf=photoDetail";
                break;
            case 6:$url="http://b400.photo.store.qq.com/psb?/V12Zu6dj2SFP8z/9R3HZs*ZDmbvdYadpZxNskdKiZw7WOLRk6yGbodn0MY!/b/dIJrd.6qFgAA&bo=gALfAQAAAAABAHs!&rf=photoDetail";
                break;
        
          default:$url = "http://b400.photo.store.qq.com/psb?/V12Zu6dj2SFP8z/9R3HZs*ZDmbvdYadpZxNskdKiZw7WOLRk6yGbodn0MY!/b/dIJrd.6qFgAA&bo=gALfAQAAAAABAHs!&rf=photoDetail";
        }






        $resultStr =
                "<xml>
		
           <ToUserName>
          		 <![CDATA[$postObj->FromUserName]]>
           </ToUserName>
           <FromUserName>
          		 <![CDATA[$postObj->ToUserName]]>
           </FromUserName>
           <CreateTime>" . time() . "</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>2</ArticleCount>
           <Articles>
           
           
            		
	   <item>
           <Title>
           		<![CDATA[一中树洞（纱帽夜广场）]]>
           </Title> 
           <Description>
          		 <![CDATA[]]>
           </Description>
           <PicUrl>
           		<![CDATA[$url]]>
           </PicUrl>
           <Url>
          		 <![CDATA[]]>
           </Url>
           </item>
           
           
           <item>
           <Title>
           		<![CDATA[$menustr]]>
           </Title> 
           <Description>
          		 <![CDATA[]]>
           </Description>
           <PicUrl>
           		<![CDATA[]]>
           </PicUrl>
           <Url>
          		 <![CDATA[]]>
           </Url>
           </item>
           
          
        
           </Articles>
           <FuncFlag>0</FuncFlag>
		   </xml>";


        echo $resultStr;
        exit;
    }

    public function weibolist($postObj) {
        $form_Content = $postObj->Content;
        include("Tpl.php");
        $mc = memcache_init();
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;

if(($mc->get($fromUsername . "_do")=="刷")&&(strtolower($form_Content)=="n"))
{
 $page_number=$mc->get($fromUsername ."page_number");
 $now_page=$mc->get($fromUsername ."now_page")+1;
 $weibo=$mc->get($fromUsername ."weibo");
 $weibo_number=$mc->get($fromUsername ."weibo_number");
    if($now_page<$page_number)
    {
         $resultStr = "<xml>
           <ToUserName><![CDATA[$fromUsername]]></ToUserName>
           <FromUserName><![CDATA[$toUsername]]></FromUserName>
           <CreateTime>".time()."</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>7</ArticleCount>
           <Articles>
           <item>
           <Title><![CDATA[微博列表]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/yVPecbR4T6ykN6waXJ1*igfeIykc1uO2n.xp4I0YViM!/b/dOzH2O2JBgAA&bo=uAEmAQAAAAABALk!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> ";
          
          
      for($i=($now_page-1)*5;$i<$now_page*5;$i++)
      {     
            $resultStr.="
           <item>
           <Title><![CDATA[".$weibo['statuses'][$i]['text']." ]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           ";
       }
            
            $resultStr.="  
            <item>
           <Title><![CDATA[回复【n】下一页\n回复【菜单】退出刷微博]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/yVPecbR4T6ykN6waXJ1*igfeIykc1uO2n.xp4I0YViM!/b/dOzH2O2JBgAA&bo=uAEmAQAAAAABALk!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> 
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";
  echo $resultStr;
  $mc->set($fromUsername . "_do", "刷", 0, 1000);
  $mc->set($fromUsername ."page_number",$page_number,0,1000);
  $mc->set($fromUsername ."now_page",1,0,1000);
  $mc->set($fromUsername ."weibo",$weibo,0,1000);
  $mc->set($fromUsername ."weibo_number",$weibo_number,0,1000);
  exit;
        
        
    }
    if($now_page==$page_number)
    {
        $ArticleCount=$weibo_number-($now_page-1)*5+2;
         $resultStr = "<xml>
           <ToUserName><![CDATA[$fromUsername]]></ToUserName>
           <FromUserName><![CDATA[$toUsername]]></FromUserName>
           <CreateTime>".time()."</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>$ArticleCount</ArticleCount>
           <Articles>
           <item>
           <Title><![CDATA[微博列表]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/yVPecbR4T6ykN6waXJ1*igfeIykc1uO2n.xp4I0YViM!/b/dOzH2O2JBgAA&bo=uAEmAQAAAAABALk!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> ";
          
          
      for($i=($now_page-1)*5;$i<$book_number;$i++)
      {      
           
            $resultStr.="
           <item>
           <Title><![CDATA[".$text."]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           ";
       }
            
            $resultStr.="  
            <item>
           <Title><![CDATA[这已经是最后一页了\n回复【菜单】退出刷微博]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> 
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";
  
           echo $resultStr;
           $mc->set($fromUsername . "_do", "刷", 0, 1000);
          $mc->set($fromUsername ."page_number",$page_number,0,1000);
           $mc->set($fromUsername ."now_page",1,0,1000);
     
           exit;
        
    }
     if($now_page>$page_number)
    {
    $contentStr="对不起，上面已经是最后一页了\n回复【菜单】退出刷微博";
    $resultStr = sprintf($textTpl, $contentStr);
    echo $resultStr;
    $mc->set($fromUsername . "_do", "刷", 0, 1000);
    exit;      
    }
    
    
}

if($form_Content="刷")
{           include("../weibo/config.php");
            include("../weibo/saetv2.ex.class.php");
           $c = new SaeTClientV2( WB_AKEY , WB_SKEY , '2.00B1DeOEJ6WssD165807f641NYaPfD' );
          $weibo=$c->user_timeline_by_id($uid,1,100);
          $weibo_number=count($weibo['statuses']);
          $page_number= floor(($weibo_number+4)/5 );  
 
  if($weibo_number==0)
  {
    $contentStr="对不起，暂无微博\n回复【菜单】显示所有功能";
    $mc->set($fromUsername . "_do", "刷", 0, 1000);
    $resultStr = sprintf($textTpl, $contentStr);
    echo $resultStr;
    exit;     
  }
    
    
    if($weibo_number<5)
        $ArticleCount=$weibo_number+2;
    else 
        $ArticleCount=7;
    
           $resultStr = "<xml>
           <ToUserName><![CDATA[$fromUsername]]></ToUserName>
           <FromUserName><![CDATA[$toUsername]]></FromUserName>
           <CreateTime>".time()."</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>$ArticleCount</ArticleCount>
           <Articles>
           <item>
           <Title><![CDATA[微博列表]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[http://b399.photo.store.qq.com/psb?/V12Zu6dj4Mwe6a/yVPecbR4T6ykN6waXJ1*igfeIykc1uO2n.xp4I0YViM!/b/dOzH2O2JBgAA&bo=uAEmAQAAAAABALk!&rf=photoDetail]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> ";
      for($i=0;$i< ($ArticleCount-2);$i++)
      {      
            $resultStr.="
           <item>
           <Title><![CDATA[".$weibo['statuses'][$i]['text']."  ]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
           ";
       }
            
            $resultStr.="  
            <item>
           <Title><![CDATA[回复【n】下一页\n回复【菜单】退出刷微博]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item> 
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";
  
  echo $resultStr;
  $mc->set($fromUsername . "_do", "刷", 0, 1000);
  $mc->set($fromUsername ."page_number",$page_number,0,1000);
  $mc->set($fromUsername ."now_page",1,0,1000);
  $mc->set($fromUsername ."weibo",$weibo,0,1000);
  $mc->set($fromUsername ."weibo_number",$weibo_number,0,1000);
  exit;
}


    }

    public function TextWeibo($postObj) {
        
        $form_Content = $postObj->Content;
        include("Tpl.php");
        $mc = memcache_init();
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;

        if ($mc->get($fromUsername . "_do") == "发布") {
            include("../weibo/config.php");
            include("../weibo/saetv2.ex.class.php");
            $c = new SaeTClientV2(WB_AKEY, WB_SKEY, '2.00B1DeOEJ6WssD165807f641NYaPfD');
            $ret = $c->update($form_Content . "【微信】"); //发送微博

            if (isset($ret['error_code']) && $ret['error_code'] > 0) {
                $contentStr = "微博发送错误\n\n回复【发布】从新发送\n回复【菜单】回到首页\n\n回复【刷】查看微博列表";
            } else {
                //$contentStr = "微博已成功发到 @纱帽夜广场\n\n回复【菜单】回到首页\n\n回复【刷】查看微博列表";
                $contentStr = "微博已成功发到@纱帽夜广场\n\n回复【菜单】回到首页\n回复【刷】查看微博列表";
            }
            $resultStr = sprintf($textTpl, $contentStr);
            $mc->delete($fromUsername . "_do", 0);
            echo $resultStr;
            exit;
        }

        if (trim($form_Content) == "发布") {
            $mc->delete($fromUsername . "_do", 0);
            $mc->set($fromUsername . "_do", "发布", 0, 600);

            $contentStr = "请在对话框输入你要发布的内容\n\n————————————\n如发布图文微博则回复【发图】\n回复【菜单】取消发布并回到首页";
            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;
            exit;
        }
    }

    public function ImgWeibo($postObj) {
        include("Tpl.php");    
        $mc = memcache_init();
        $form_Content = trim($postObj->Content);
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;

       if ($mc->get($fromUsername . "_do") == "发图") {
            $contentStr = "请添加图片。回复【菜单】退出发图并回到主页";    
            $resultStr = sprintf($textTpl, $contentStr);
           
            $mc->set($fromUsername . "_text", $form_Content,0,600);
            echo $resultStr;
            $mc->delete($fromUsername."_do", 0);
            exit;
        }

        if ($form_Content == "发图") {
            $mc->delete($fromUsername . "_do", 0);
            $mc->set($fromUsername . "_do", "发图", 0, 1000);
            
            $contentStr = "请先输入文字消息\n\n——————————————\n回复【菜单】取消发布并回到首页";
            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;
            exit;
        }
    }

    public function mail($postObj) {
        $form_Content = trim($postObj->Content);
        include("Tpl.php");
        $mc = memcache_init();
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;

        if ($mc->get($fromUsername . "_do") == "留言") {
            $mc->set($fromUsername . "_do", "留言", 0, 600);
            $mail = new SaeMail();
            $mail->quickSend("@qq.com", "微信ID号：" . $fromUsername . "给你发的邮件", $form_Content, "524106731@qq.com", "ouminghai");
            $contentStr = "\n留言成功.感谢你对开发者的支持\n回复【菜单】返回功能列表";
             $resultStr = sprintf($textTpl, $contentStr);
            $mc->delete($fromUsername . "_do", 0);
            echo $resultStr;
            exit;
        }

        if ($form_Content == "留言") {
            $mc->delete($fromUsername . "_do", 0);
            $mc->set($fromUsername . "_do", "留言", 0, 600);

            $contentStr = "进入留言模式。如果有任何疑问，可发送任何内容进行留言。\n回复【菜单】取消留言";
            
            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;
            exit;
        }
    }

    public function weather($postObj) {
        $form_Content = trim($postObj->Content);
        include("Tpl.php");
        $mc = memcache_init();
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;


        $resultStr;
        for ($i = 0; $i <= 2; $i++) {
            $f = new SaeFetchurl();
            $day = "&day=" . $i;
            $url = "http://php.weather.sina.com.cn/xml.php?city=%CC%A8%C9%BD&password=DJOYnieT8234jlsK" . $day;
            $weather = $f->fetch($url);
            //用正则表达式获取数据
            preg_match_all("/\<city\>(.*?)\<\/city\>/", $weather, $w_city);
            preg_match_all("/\<status2\>(.*?)\<\/status2\>/", $weather, $w_status2);
            preg_match_all("/\<status1\>(.*?)\<\/status1\>/", $weather, $w_status1);
            preg_match_all("/\<temperature2\>(.*?)\<\/temperature2\>/", $weather, $w_temperature2);
            preg_match_all("/\<temperature1\>(.*?)\<\/temperature1\>/", $weather, $w_temperature1);
            preg_match_all("/\<chy_shuoming\>(.*?)\<\/chy_shuoming\>/", $weather, $w_chy_shuoming);
            preg_match_all("/\<yd_s\>(.*?)\<\/yd_s\>/", $weather, $w_yds);
            preg_match_all("/\<savedate_weather\>(.*?)\<\/savedate_weather\>/", $weather, $w_savedate_weather);
            //如果天气变化一致
            if ($w_status2 == $w_status1) {
                $w_status = $w_status2[1][0];
            } else {
                $w_status = $w_status2[1][0] . "转" . $w_status1[1][0];
            }
            //将获取到的数据拼接起来
            $weather_res = "一中天气预报" .
                    "\n发布时间：" . $w_savedate_weather[1][0] .
                    "\n天气：" . $w_status .
                    "\n气温：" . $w_temperature2[1][0] . "-" . $w_temperature1[1][0] .
                    "\n出行：" . $w_yds[1][0] .
                    "\n穿衣：" . $w_chy_shuoming[1][0] . "\n\n\n\n";
            $resultStr.= $weather_res;
        }

        $resultStr.="天气消息来源于新浪天气\n回复【菜单】返回首页";
        $result = sprintf($textTpl, $resultStr);
        echo $result;
        exit;
    }

    public function simsimi($postObj) {
        $form_Content = trim($postObj->Content);
        include("Tpl.php");
        $mc = memcache_init();
        $address_book = $this->address_book;
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;

        if ($mc->get($fromUsername . "_do") == "鸡鸡") {
            $mc->set($fromUsername . "_do", "鸡鸡", 0, 6000);

            do {

                $f = new SaeFetchurl();
                $f->setMethod("post");
                $f->setPostData(
                        array(
                            "chat" =>$form_Content ,
                        )
                );
                $data = $f->fetch("http://www.xiaojo.com/bot/chata.php");
                $checkdata = str_replace(" ", "", $data);
                $domain = strstr($checkdata, '微信');
            } while ($domain != NULL);

            if ($data != '') {
                $resultStr = sprintf($textTpl, $data);
                echo $resultStr;
                exit;
            } else {
                $ran = rand(1, 6);

                switch ($ran) {
                    case 1:$data = "么么哒";
                        break;

                    case 2:$data = "想你了";
                        break;

                    case 3:$data = "花开富贵";
                        break;

                    case 4:$data = "生日快乐";
                        break;

                    case 5:$data = "我爱你";
                        break;

                    case 6:$data = "恭喜发财";
                        break;

                    default:$data = "年年有余";
                }
                $resultStr = sprintf($textTpl, $data);
                echo $resultStr;
                exit;
            }
        }
        if ($form_Content == "鸡鸡") {
            $mc->delete($fromUsername . "_do", 0);
            $mc->set($fromUsername . "_do", "鸡鸡", 0, 6000);

            $contentStr = "小黄鸡：\n" . $address_book['student_name'] . "\n我是小simsimi!快来调戏我吧\n\n菜单提示：回复【菜单】退出simsimi";

            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;
            exit;
        }
    }

    public function about($postObj) {



        $textTpl = "<xml>
            <ToUserName><![CDATA[$postObj->FromUserName]]></ToUserName>
            <FromUserName><![CDATA[$postObj->ToUserName]]></FromUserName>
            <CreateTime>" . time() . "</CreateTime>
            <MsgType><![CDATA[text]]></MsgType>
            <Content>联系开发者可回复【留言】\n本工具由&lt;a href=&quot; http://tsyz.sinaapp.com/weibo/index.php &quot;&gt;@纱帽夜广场&lt;/a&gt;开发</Content>
            <FuncFlag>0</FuncFlag>
             </xml>";
        $resultStr = sprintf($textTpl);
        echo $resultStr;
        exit;
    }

    public function error($postObj) {
        $mc = memcache_init();
        include("Tpl.php");
        $contentStr = "对不起   此功能暂未开通  回复【菜单】返回主页 ";
        $description = "输入【菜单】返回 ";
        $resultStr = sprintf($imageTpl, $contentStr, $description, "", "");
        $mc->delete($postObj->FromUserName . "_do", 0);
        $mc->delete($postObj->FromUserName . "__page", 0);
        echo $resultStr;
        exit;
    }

    public function uploadimg($postObj) {
        include("Tpl.php");
        include("../weibo/config.php");
        include("../weibo/saetv2.ex.class.php");
        $mc = memcache_init();
        $fromUsername = $postObj->FromUserName;
        $toUsername = $postObj->ToUserName;
        $PicUrl = $postObj->PicUrl;
        //创建新的图片名称
        $NewName = $fromUsername . date("YmdHis") . ".jpg";
        //创建抓取图片类
        $f = new SaeFetchurl();
        //抓取图片
        $res = $f->fetch($PicUrl);
        //如果抓取到图片
        if ($f->errno() == 0) {
            //新建存储类
            $s = new SaeStorage();
            //写入图片
            $s->write("image", $NewName, $res);
            
            $PicUrl = $s->getUrl("image", $NewName);
            
            $text = $mc->get($fromUsername . "_text");
                    $mc->delete($fromUsername . "_text",0);
            if ($text == '')
            $text = "分享图片";
            
            $text.="【微信】";
            $c = new SaeTClientV2(WB_AKEY, WB_SKEY, '2.00B1DeOEJ6WssD165807f641NYaPfD');
            $ret = $c->upload($text, $PicUrl); //发送图片微博

            if (isset($ret['error_code']) && $ret['error_code'] > 0) {
                $contentStr = "微博发送错误\n\n回复【发布】从新发送\n回复【菜单】回到首页";
            } else {
                $contentStr = "微博已成功发到@纱帽夜广场\n\n回复【菜单】回到首页\n回复【刷】查看微博列表";
            }
           
            $resultStr = sprintf($textTpl, $contentStr);
            echo $resultStr;

            exit;
        } 
        else {
            $contentStr = "图片上传失败\n\n回复【发图】从新发送\n回复【菜单】回到首页";
            echo $resultStr;
            exit;
        }
    }

	public function takeawaymenu($postObj){
	
	       $title="请输入【】内文字选择类别:\n\n【中餐】中式快餐\n【西餐】西式快餐\n【奶茶】奶茶小吃\n【咖啡】咖啡厅\n【KTV】KTV酒吧\n【排档】大排档\n";
 
        	$resultStr = "<xml>
           <ToUserName><![CDATA[$postObj->FromUserName]]></ToUserName>
           <FromUserName><![CDATA[$postObj->ToUserName]]></FromUserName>
           <CreateTime>".time()."</CreateTime>
           <MsgType><![CDATA[news]]></MsgType>
           <ArticleCount>2</ArticleCount>
           <Articles>
           <item>
           <Title><![CDATA[外卖类别]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
		   
		   <item>
           <Title><![CDATA[".$title."]]></Title> 
           <Description><![CDATA[]]></Description>
           <PicUrl><![CDATA[]]></PicUrl>
           <Url><![CDATA[]]></Url>
           </item>
		   
           </Articles>
           <FuncFlag>1</FuncFlag>
           </xml> ";
		   
		   
           echo $resultStr;
           exit;
	
}
}
?>
